let vue = new Vue({
    'el':'#app',
     // 修改Vue读取变量的语法，防止与jinja2混淆
    delimiters: ['[[', ']]'],
    data:function (){
        return {
            username:''
        }
    },
    mounted(){
        // 从cookie中获取username
        this.username = this.getCookie("username")
    },
    methods:{
        //获取cookie
        getCookie(key){
            let cookiename = key +"=";
            let value = '';
            const cookies = document.cookie.split(";")
            cookies.forEach(cookie => {
                if (cookie.indexOf(cookiename)!=-1){
                    value = cookie.substring(cookiename.length,cookie.length)
                }
            })
            return value
        }
    }
})